﻿#region Using Directives

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;

    using Csla;

    using MarketPulse.BusinessLogic.Core;

#endregion

namespace MarketPulse.BusinessLogic.Common
{
    /// <summary>
    /// This class represents a read only collection of (read only) Accreditation objects
    /// </summary>
    [Serializable]
    [Csla.Server.ObjectFactory("MarketPulse.DataAccess.Factory.AccreditationFactory, MarketPulse.DataAccess.Factory", "FetchInfoList")]
    public class AccreditationInfoList : MarketPulseReadOnlyListBase<AccreditationInfoList, AccreditationInfo>
    {

        #region Constructors

            /// <summary>
            /// Default constructor is private in order to (try to) enforce construction
            /// only via the static factory methods provided.
            /// </summary>
            private AccreditationInfoList()
            {
            }

        #endregion

        #region Methods

            #region Factory Methods

                /// <summary>
                /// Method used to get a list of Accreditations that are currently not obsolete
                /// </summary>                
                /// <returns>The populated read only Accreditation collection</returns>
                public static AccreditationInfoList GetAllActive()
                {
                    return DataPortal.Fetch<AccreditationInfoList>();
                }

            #endregion

                /// <summary>
                /// Method used to find a single AccreditationInfo object from the collection based on the unique identifier supplied
                /// </summary>
                /// <param name="accreditationGUID">The GUID that uniquely identifies the Accreditation Info object to find</param>
                /// <returns>A populated Accreditation Info object</returns>
                public AccreditationInfo FindByGUID(Guid accreditationGUID)
                {
                    var result = (from accreditation in this.Items
                                  where accreditation.GUID.Value == accreditationGUID
                                  select accreditation).Single();

                    return (AccreditationInfo)result;
                }

        #endregion
    }
}
